

import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router'

//创建路由数组，用于存放每一个组件的路由地址 RouteRecordRaw() 用于申明路由记录的类型
const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'Demo',
        component: () => import('../components/Demo.vue')
    },
    {
        path: '/StuShow',
        name: 'StuShow',
        component: () => import('../components/StuShow.vue')
    },
    {
        path: '/StuEdit/:id',
        name: 'StuEdit',
        component: () => import('../components/StuEdit.vue')
    }
]

//通过createRouter() 创建路由 createWebHistory() 创建路由历史记录的函数
const router = createRouter({
    //声明路由模式
    history: createWebHistory(),
    //通过数组保存路由信息
    routes
})

//导出路由  
export default router